package com.ruoyi.web.controller.teacher;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.domain.BasisBatteryEnvironment;
import com.ruoyi.service.IBasisBatteryEnvironmentService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;

import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 电池环境数据Controller
 *
 * @author ruoyi
 * @date 2025-07-16
 */
@RestController
@RequestMapping("/system/environment")
public class BasisBatteryEnvironmentController extends BaseController
{
    @Autowired
    private IBasisBatteryEnvironmentService basisBatteryEnvironmentService;

    /**
     * 查询电池环境数据列表
     */
    @GetMapping("/list")
    public TableDataInfo list(BasisBatteryEnvironment basisBatteryEnvironment)
    {
        startPage();
        List<BasisBatteryEnvironment> list = basisBatteryEnvironmentService.selectBasisBatteryEnvironmentList(basisBatteryEnvironment);
        return getDataTable(list);
    }

    /**
     * 导出电池环境数据列表
     */
    @Log(title = "电池环境数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BasisBatteryEnvironment basisBatteryEnvironment)
    {
        List<BasisBatteryEnvironment> list = basisBatteryEnvironmentService.selectBasisBatteryEnvironmentList(basisBatteryEnvironment);
        ExcelUtil<BasisBatteryEnvironment> util = new ExcelUtil<BasisBatteryEnvironment>(BasisBatteryEnvironment.class);
        util.exportExcel(response, list, "电池环境数据数据");
    }

    /**
     * 获取电池环境数据详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(basisBatteryEnvironmentService.selectBasisBatteryEnvironmentById(id));
    }

    /**
     * 新增电池环境数据
     */
    @Log(title = "电池环境数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BasisBatteryEnvironment basisBatteryEnvironment)
    {
        return toAjax(basisBatteryEnvironmentService.insertBasisBatteryEnvironment(basisBatteryEnvironment));
    }

    /**
     * 修改电池环境数据
     */
    @Log(title = "电池环境数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BasisBatteryEnvironment basisBatteryEnvironment)
    {
        return toAjax(basisBatteryEnvironmentService.updateBasisBatteryEnvironment(basisBatteryEnvironment));
    }

    /**
     * 删除电池环境数据
     */
    @Log(title = "电池环境数据", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(basisBatteryEnvironmentService.deleteBasisBatteryEnvironmentByIds(ids));
    }
}